import { useEffect, useRef } from 'react';
import { Application } from '@manycore/custom-ksg-viewer-sdk';
import './index.less';
import { AppStore } from '../../store';

export function Viewer() {

    const ref = useRef<HTMLDivElement>(null);
    const { appState: { app }, updateApplication } = AppStore.useContainer();

    useEffect(() => {
        if (ref.current) {
            const app = new Application(ref.current);
            updateApplication(app);
        }
    }, [ref]);


    return (<div className='app-view-root' ref={ref}></div>)
}
